﻿<%@ Page Language="C#" AutoEventWireup="true" Inherits="ZX.Web.UI.Controls.BasePage" %>


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title>多文件上传示例</title>
    <style>#btnSubmit { margin: 0 0 0 155px ; }
/* -- Table Styles ------------------------------- */
td {
	font: 10pt Helvetica, Arial, sans-serif;
	vertical-align: top;
}

.progressWrapper {
	width: 357px;
	overflow: hidden;
}

.progressContainer {
	margin: 5px;
	padding: 4px;
	border: solid 1px #E8E8E8;
	background-color: #F7F7F7;
	overflow: hidden;
}
/* Message */
.message {
	margin: 1em 0;
	padding: 10px 20px;
	border: solid 1px #FFDD99;
	background-color: #FFFFCC;
	overflow: hidden;
}
/* Error */
.red {
	border: solid 1px #B50000;
	background-color: #FFEBEB;
}

/* Current */
.green {
	border: solid 1px #DDF0DD;
	background-color: #EBFFEB;
}

/* Complete */
.blue {
	border: solid 1px #CEE2F2;
	background-color: #F0F5FF;
}

.progressName {
	font-size: 8pt;
	font-weight: 700;
	color: #555;
	width: 323px;
	height: 14px;
	text-align: left;
	white-space: nowrap;
	overflow: hidden;
}

.progressBarInProgress,
.progressBarComplete,
.progressBarError {
	font-size: 0;
	width: 0%;
	height: 2px;
	background-color: blue;
	margin-top: 2px;
}

.progressBarComplete {
	width: 100%;
	background-color: green;
	visibility: hidden;
}

.progressBarError {
	width: 100%;
	background-color: red;
	visibility: hidden;
}

.progressBarStatus {
	margin-top: 2px;
	width: 337px;
	font-size: 7pt;
	font-family: Arial;
	text-align: left;
	white-space: nowrap;
}

a.progressCancel {
	font-size: 0;
	display: block;
	height: 14px;
	width: 14px;
	background-image: url(../images/cancelbutton.gif);
	background-repeat: no-repeat;
	background-position: -14px 0px;
	float: right;
}

a.progressCancel:hover {
	background-position: 0px 0px;
}


/* -- SWFUpload Object Styles ------------------------------- */
.swfupload {
	vertical-align: top;
}

.toolbar {
    background-color: #fff;
    width: 98%;
    bottom: 0px;
    position: absolute;
    height: 34px;
    padding-top: 2px;
    padding-bottom: 2px;
    z-index: 100;
    border-top: 1px solid #B4C9C6;
    text-align: right;
}
</style>
    <script src="/SFramework/boot.js"></script>
    <script type="text/javascript" src="/SFramework/miniui/swfupload/swfupload.js"></script>
     <script type="text/javascript" src="/SFramework/miniui/swfupload/fileprogress.js"></script>
    <script  type="text/javascript" src="/SFramework/miniui/swfupload/handlers.js"></script>
    <script  type="text/javascript" src="/SFramework/miniui/swfupload/swfupload.queue.js"></script>
    <script src="/SFramework/jquery.json-2.2.js"></script>
    <script type="text/javascript">
        var swfu;
        var function_id = "<%=GetStringFromQueryString("functionid","")%>";
        var entity = "<%=GetStringFromQueryString("entity","")%>";
        var field = "<%=GetStringFromQueryString("field","")%>";
        var action = "<%=GetStringFromQueryString("action","")%>";
        var limitExt = "<%=GetStringFromQueryString("limitExt","*.*")%>";
        var limit = <%=GetIntFromQueryString("limit",1)%>;
        //limit=limit==0?1:limit;
        window.onload = function () {
            var settings = {
                flash_url: "/SFramework/miniui/swfupload/swfupload.swf",
                upload_url: "upload.aspx?action=set&limit="+limit+"&entity="+entity+"&field="+field+"&action="+action+"&functionid="+function_id,
                post_params: {
                    "ASPSESSID": "<%=Session.SessionID %>"
            },
            file_size_limit: "100 MB",
            file_types: limitExt,
            file_types_description: "All Files",
            file_upload_limit: limit,
            file_queue_limit: 0,
            custom_settings: {
                progressTarget: "fsUploadProgress",
                cancelButtonId: "btnCancel"
            },
            debug: false,

            // Button settings
            button_image_url: "images/XPButtonNoText_160x22.png",
            button_placeholder_id: "btnUpload",
            button_width: 160,
            button_height: 22,
            button_text: '<span class="button">&nbsp; &nbsp;选择文件 &nbsp;  &nbsp;<span class="buttonSmall">(2 MB Max)</span></span>',
            button_text_style: '.button { font-family: Helvetica, Arial, sans-serif; font-size: 14pt; } .buttonSmall { font-size: 10pt; }',
            button_text_top_padding: 1,
            button_text_left_padding: 5,

            // The event handler functions are defined in handlers.js
            file_queued_handler: fileQueued,
            file_queue_error_handler: fileQueueError,
            file_dialog_complete_handler: fileDialogComplete,
            upload_start_handler: uploadStart,
            upload_progress_handler: uploadProgress,
            upload_error_handler: uploadError,
            upload_success_handler: uploadSuccess,
            upload_complete_handler: uploadComplete,
            queue_complete_handler: queueComplete	// Queue plugin event
        };

        swfu = new SWFUpload(settings);
        };

        function fileQueued() { };

        //////////////////////////////////
        function CloseWindow(action) {
            if (window.CloseOwnerWindow) return window.CloseOwnerWindow(action);
            else window.close();
        }

        function fnGetData(){
            return _data;
        }

        var _data = [];
        function fnSetData(data) {
            _data.push(_data);
        }


        function fnDataBinding(){
            grid.selects (_data, true )
        }

        function onOk() {
            CloseWindow("ok");        
        }
        function onCancel() {
            CloseWindow("cancel");
        }

        

        var fnClose = function () {
            window.CloseOwnerWindow();
        };





        ///上传成功后缓存上传文件信息
        function uploadSuccess(file, serverData) {
            try {
                var progress = new FileProgress(file, this.customSettings.progressTarget);
                progress.setComplete();
                progress.setStatus("Complete.");
                progress.toggleCancel(false);
                var data =$.evalJSON( serverData);
                fnSetData(data);
                $("#divHTML").html(serverData);
            } catch (ex) {
                this.debug(ex);
            }
        }

        function fnOK(){
            onOk();
        }
    </script>
</head>
<body>
    <div id="content">
        <h4>一次选择一个或多个文件进行上传</h4>
        <form id="form1" runat="Server">


            <div>
                <input id="btnUpload" type="button" value="全部上传" />
                <input id="btnCancel" type="button" value="取消全部上传" onclick="swfu.cancelQueue();" disabled="disabled" style="margin-left: 2px; font-size: 8pt; height: 22px;" />
            </div>
            <p>&nbsp;</p>
            <div class="fieldset flash" id="fsUploadProgress">
                <span class="legend">Upload Queue</span>
            </div>
            <div style="width:98%;height:100px;overflow:hidden;">
            <div id="divStatus">0 个文件已经上传</div>
            <div id="divHTML"></div>
            </div>

        </form>
    </div>
        <div class="toolbar">
        <button id="btnOK">确定</button>
        <button id="btnCancel2">取消</button>
    </div>
</body>
</html>
<script>

    $(document).ready(function () {
        $("#btnOK").click(fnOK);
            $("#btnCancel2").click(fnClose);
    });
</script>
